﻿@page "/locator"
@inject IStringLocalizer<Locators> Localizer
@inject WebClientService ClientService
@inject IIPLocatorProvider IPLocator

<h3>@Localizer["LocatorsTitle"]</h3>

<h4>@Localizer["LocatorsSubTitle"]</h4>

<DemoBlock Title="@Localizer["LocatorsNormalTitle"]" Introduction="@Localizer["LocatorsNormalIntro"]" Name="Normal">
    <p><b>@Localizer["LocatorsNormalDescription"]</b></p>
    <p>@((MarkupString)Localizer["LocatorsNormalInjectIPLocator"].Value)</p>
    <Pre>[Inject]
[NotNull]
private IIPLocatorProvider? IPLocator { get; set; }
</Pre>
    <Tips>
        <div>@((MarkupString)Localizer["LocatorsNormalTipsTitle"].Value)</div>
        <div><b>@Localizer["LocatorsNormalTips1"]</b></div>
        <div>@((MarkupString)Localizer["LocatorsNormalTips2"].Value)</div>
    </Tips>
    <Pre>Encoding.RegisterProvider(CodePagesEncodingProvider.Instance)</Pre>
    <p><b>@Localizer["LocatorsNormalExtendDescription"]</b></p>
    <p><b>@Localizer["LocatorsNormalExtend1"]</b></p>
    <Pre>private class CustomerLocator : IIPLocator
{
    public Task&lt;string&gt; Locate(IPLocatorOption option)
    {
        throw new NotImplementedException();
    }
}</Pre>
    <p><b>@Localizer["LocatorsNormalExtend2"]</b></p>
    <Pre>public void ConfigureServices(IServiceCollection services)
{
    services.AddBootstrapBlazor(locatorAction: option =>
    {
        option.LocatorFactory = provider => new CustomerLocator();
    });
}</Pre>
    <p>@((MarkupString)Localizer["LocatorsNormalCustomerLocator"].Value)</p>
    <p>@Localizer["LocatorsNormalIpTitle"]</p>
    <p><code>112.224.74.239</code> @Localizer["LocatorsNormalTips3"]</p>
    <p><code>183.160.236.53</code> @Localizer["LocatorsNormalTips4"]</p>
    <div class="row g-3 form-inline">
        <div class="col-12 col-sm-6">
            <BootstrapInput @bind-Value="Ip" DisplayText="@Localizer["LocatorsNormalInputText"]" ShowLabel="true" />
        </div>
        <div class="col-12 col-sm-6">
            <Display Value="Location" DisplayText="@Localizer["LocatorsNormalDisplayText"]" ShowLabel="true" />
        </div>
        <div class="col-12">
            <Button Icon="fa-solid fa-location-arrow" Text="@Localizer["LocatorsNormalButtonText"]" OnClick="OnClick" />
        </div>
    </div>
</DemoBlock>
